<html class="no-js" lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>Dashboard V.1 | Kiaalap - Kiaalap Admin Template</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- favicon
		============================================ -->
    <link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico">
    <!-- Google Fonts
		============================================ -->
    <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,700,900" rel="stylesheet">
    <!-- Bootstrap CSS
		============================================ -->
    <link rel="stylesheet" href="css/bootstrap.min.css">

    <!-- Lobibox CSS
        ============================================ -->
    <link rel="stylesheet" href="css/notifications/Lobibox.min.css">

    <!-- Bootstrap CSS
		============================================ -->
    <link rel="stylesheet" href="css/font-awesome.min.css">


    <!-- DatetimePicker CSS
        ============================================ -->
    <link rel="stylesheet" href="css/datetimepicker/bootstrap-datetimepicker.min.css">

    <!-- owl.carousel CSS
		============================================ -->
    <link rel="stylesheet" href="css/owl.carousel.css">
    <link rel="stylesheet" href="css/owl.theme.css">
    <link rel="stylesheet" href="css/owl.transitions.css">
    <!-- animate CSS
		============================================ -->
    <link rel="stylesheet" href="css/animate.css">
    <!-- normalize CSS
		============================================ -->
    <link rel="stylesheet" href="css/normalize.css">
    <!-- meanmenu icon CSS
		============================================ -->
    <link rel="stylesheet" href="css/meanmenu.min.css">
    <!-- main CSS
		============================================ -->
    <link rel="stylesheet" href="css/main.css">
    <!-- educate icon CSS
		============================================ -->
    <link rel="stylesheet" href="css/educate-custon-icon.css">
    <!-- morrisjs CSS
		============================================ -->
    <link rel="stylesheet" href="css/morrisjs/morris.css">
    <!-- mCustomScrollbar CSS
		============================================ -->
    <link rel="stylesheet" href="css/scrollbar/jquery.mCustomScrollbar.min.css">
    <!-- metisMenu CSS
		============================================ -->
    <link rel="stylesheet" href="css/metisMenu/metisMenu.min.css">
    <link rel="stylesheet" href="css/metisMenu/metisMenu-vertical.css">
    <!-- calendar CSS
		============================================ -->
    <link rel="stylesheet" href="css/calendar/fullcalendar.min.css">
    <link rel="stylesheet" href="css/calendar/fullcalendar.print.min.css">

    <!-- form CSS
		============================================ -->
    <link rel="stylesheet" href="css/form/all-type-forms.css">

    <!-- style CSS
		============================================ -->
    <link rel="stylesheet" href="css/style.css">
    <!-- responsive CSS
		============================================ -->
    <link rel="stylesheet" href="css/responsive.css">
    <!-- modernizr JS
		============================================ -->
    <script src="js/jquery.min.js"></script>

    <script src="js/vendor/modernizr-2.8.3.min.js"></script>
    <script src="js/vue.js"></script>
    <script src="js/jquery.cookie.min.js"></script>
    <script src="js/login-status.js"></script>

</head>

<body>
<!--[if lt IE 8]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade
    your browser</a> to improve your experience.</p>
<![endif]-->
<!-- Start Left menu area -->
<div class="left-sidebar-pro">
    <nav id="sidebar" class="">
        <div class="sidebar-header">
            <a href="index.html"><img class="main-logo" src="img/logo/logo.png" alt=""/></a>
            <strong><a href="index.html"><img src="img/logo/logosn.png" alt=""/></a></strong>
        </div>
        <div class="left-custom-menu-adp-wrap comment-scrollbar">
            <nav class="sidebar-nav left-sidebar-menu-pro">
                <ul class="metismenu" id="menu1">
                    <li class="active">
                        <a class="has-arrow" href="index.html">
                            <span class="fa fa-id-card"></span>
                            <span class="mini-click-non">用户信息</span>
                        </a>
                        <ul class="submenu-angle" aria-expanded="true">
                            <li><a href="dataStatistics.html"><span class="mini-sub-pro">图表信息统计</span></a></li>
                            <li><a href="index.html"><span class="mini-sub-pro">用户列表</span></a></li>
                            <li><a href="goodsManager.html"><span class="mini-sub-pro">商品列表</span></a></li>
                            <li><a href="order.html"><span class="mini-sub-pro">订单管理</span></a></li>
                            <li><a href="payPage.html"><span class="mini-sub-pro">支付流水列表</span></a></li>
                            <li><a href="logManagement.html"><span class="mini-sub-pro">日志管理</span></a></li>
                            <li><a href="dataPush.html"><span class="mini-sub-pro">级光推送</span></a></li>

                        </ul>
                    </li>
                    <li>
                        <a title="Landing Page" href="sysUser.html" aria-expanded="false"><span
                                class="fa fa-user-circle-o" aria-hidden="true"></span> <span
                                class="mini-click-non">系统用户</span></a>
                    </li>

                </ul>
            </nav>
        </div>
    </nav>
</div>
<!-- End Left menu area -->
<!-- Start Welcome area -->
<div class="all-content-wrapper">
    <div class="container-fluid">
        <div class="row">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div class="logo-pro">
                    <a href="index.html"><img class="main-logo" src="img/logo/logo.png" alt=""/></a>
                </div>
            </div>
        </div>
    </div>
    <div class="header-advance-area">
        <div class="header-top-area">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <div class="header-top-wraper">
                            <div class="row">
                                <div class="col-lg-1 col-md-0 col-sm-1 col-xs-12">
                                    <div class="menu-switcher-pro">
                                        <button type="button" id="sidebarCollapse"
                                                class="btn bar-button-pro header-drl-controller-btn btn-info navbar-btn">
                                            <i class="fa fa-bars"></i>
                                        </button>
                                    </div>
                                </div>
                                <div class="col-lg-6 col-md-7 col-sm-6 col-xs-12">
                                    <div class="header-top-menu tabl-d-n">
                                        <ul class="nav navbar-nav mai-top-nav">
                                            <li class="nav-item"><a href="#" class="nav-link"></a>
                                            </li>
                                            <li class="nav-item"><a href="#" class="nav-link"></a>
                                            </li>
                                            <li class="nav-item"><a href="#" class="nav-link"></a>
                                            </li>
                                            <li class="nav-item dropdown res-dis-nn">

                                                <div role="menu" class="dropdown-menu animated zoomIn">
                                                    <a href="#" class="dropdown-item">Documentation</a>
                                                    <a href="#" class="dropdown-item">Expert Backend</a>
                                                    <a href="#" class="dropdown-item">Expert FrontEnd</a>
                                                    <a href="#" class="dropdown-item">Contact Support</a>
                                                </div>
                                            </li>
                                            <li class="nav-item"><a href="#" class="nav-link"></a>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                                <div class="col-lg-5 col-md-5 col-sm-12 col-xs-12">
                                    <div class="header-right-info">
                                        <ul class="nav navbar-nav mai-top-nav header-right-menu">
                                            <li class="nav-item">
                                                <a href="#" data-toggle="dropdown" role="button" aria-expanded="false"
                                                   class="nav-link dropdown-toggle">


                                                    <span class="admin-name" id="admin-name">用户管理</span>
                                                    <span class="admin-name2" id="admin-nam2"></span>
                                                </a>
                                                <ul role="menu"
                                                    class="dropdown-header-top author-log dropdown-menu animated zoomIn">
                                                    <li><a href="sysUser.html"><span
                                                            class="edu-icon edu-home-admin author-log-ic"></span><button>管理员信息</button></a>
                                                    <li><a><span
                                                            class="edu-icon edu-settings author-log-ic"></span><button  onclick="loginOut()">切换登录</button></a>
                                                    <li><a><span
                                                            class="edu-icon edu-settings author-log-ic" ></span><button onclick="loginOut()">退出登录</button>
                                                    </a></li>

                                                </ul>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="container-fluid" style="padding: 20px 15px 0 15px;">


            <!-- 支付流水页面 -->

            <form class="form-inline" onsubmit="javascript: return false;">
                <div class="form-group">
                    <label for="name">支付用户: </label>
                    <input autocomplete="off" class="form-control" id="name">
                </div>
                <div class="form-group">
                    <label for="phone">支付用户电话: </label>
                    <input autocomplete="off" class="form-control" id="phone">
                </div>
                <div class="form-group">
                    <label for="status">支付状态: </label>
                    <select class="form-control" id="status">
                        <option value="-1">全部</option>
                        <option value="TRADE_FAIL">不可用</option>
                        <option value="TRADE_SUCCESS">已支付</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="method">支付方式: </label>
                    <select class="form-control" id="method">
                        <option value= -1>全部</option>
                        <option value= 1>支付宝支付</option>
                        <option value= 2>微信支付</option>
                    </select>
                </div>
                <div class="form-group">
                    <label>支付时间: </label>
                    <input class="form-control" readonly autocomplete="off" id="beginRegisterDate"> -
                    <input autocomplete="off" readonly class="form-control" id="endRegisterDate">
                </div>
                <div class="form-group">
                    <button class="btn btn-danger" onclick="querySearch()">搜索</button>
                    <button autocomplete="off" class="btn btn-danger" onclick="resetSearch()">重置</button>
                </div>
            </form>

        <table id="goodsDataTable" class="table table-bordered table-striped"></table>



               <!-- 尾部页面 -->

            </div>
        </div>
        </div>

        <!-- jquery
        ============================================ -->
        <script src="js/vendor/jquery-1.12.4.min.js"></script>
        <!-- bootstrap JS
        ============================================ -->
        <script src="js/bootstrap.min.js"></script>
        <!-- wow JS  动画效果js
        ============================================ -->
        <script src="js/wow.min.js"></script>
        <!-- price-slider JS
        ============================================ -->
        <script src="js/jquery-price-slider.js"></script>
        <!-- meanmenu JS
        ============================================ -->
        <script src="js/jquery.meanmenu.js"></script>
        <!-- owl.carousel JS
        ============================================ -->
        <script src="js/owl.carousel.min.js"></script>
        <!-- sticky JS
        ============================================ -->
        <script src="js/jquery.sticky.js"></script>
        <!-- scrollUp JS
        ============================================ -->
        <script src="js/jquery.scrollUp.min.js"></script>
        <!-- counterup JS
        ============================================ -->
        <script src="js/counterup/jquery.counterup.min.js"></script>
        <script src="js/counterup/waypoints.min.js"></script>
        <script src="js/counterup/counterup-active.js"></script>
        <!-- mCustomScrollbar JS
        ============================================ -->
        <script src="js/scrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
        <script src="js/scrollbar/mCustomScrollbar-active.js"></script>
        <!-- metisMenu JS
        ============================================ -->
        <script src="js/metisMenu/metisMenu.min.js"></script>
        <script src="js/metisMenu/metisMenu-active.js"></script>


        <script src="js/sparkline/jquery.sparkline.min.js"></script>
        <script src="js/sparkline/jquery.charts-sparkline.js"></script>
        <script src="js/sparkline/sparkline-active.js"></script>
        <!-- calendar JS
        ============================================ -->
        <script src="js/calendar/moment.min.js"></script>

        <script src="js/calendar/fullcalendar.min.js"></script>
        <script src="js/calendar/fullcalendar-active.js"></script>
        <!-- plugins JS
        ============================================ -->
        <script src="js/plugins.js"></script>
        <!-- main JS
        ============================================ -->
        <script src="js/main.js"></script>

        <!-- tawk chat JS  聊天系统js
        <script src="js/tawk-chat.js"></script>
        ============================================ -->

        <script src="js/data-table/bootstrap-table.js"></script>
        <script src="js/data-table/bootstrap-table-zh-CN.js"></script>

        <script src="js/notifications/Lobibox.js"></script>
        <script src="js/datepicker/bootstrap-datetimepicker.min.js"></script>
        <script src="js/datepicker/bootstrap-datetimepicker.zh-CN.js"></script>
        <script src="js/jquery.cookie.min.js"></script>
        <script src="js/login-status.js"></script>
        </body>
        <script>
            function determineLogin(){
                $.ajax({
                    url:'http://localhost:8080/sysUser/determineLogin',
                    method:'get',
                    data:{},
                    success:function(_data){
                        console.log("已登录状态")
                }, error: function (_data) {
                        alert("请先登录");
                        window.location = "/shop/login.html";
                    }
                })
            }
            determineLogin();

            $('#goodsDataTable').bootstrapTable({

                url: 'http://localhost:8080/pay',
                method: 'GET',
                columns: [
                    // field是返回rows中每个对象的属性名
                    {title: '支付状态', field: 'tradeStatus', align: 'center',formatter: formatStatus},
                    {title: '支付用户', field: 'address.aname'},
                    {title: '支付用户电话', field: 'address.aphone'},
                    {title: '订单编号', field: 'orderOn',formatter: formatTitle},
                    {title: '支付描述', field: 'payInfo',formatter: formatTitle},
                    {title: '支付宝交易号', field: 'tradeNo',formatter: formatTitle},
                    {title: '支付价格', field: 'totalAmount'},
                    {title: '支付方式', field: 'payWay',formatter:formatMethod},
                    {title: '支付流水创建时间', field: 'updateTime',formatter: formatTime},
                    {title: '操作',formatter: addProcessBtn}
                ],
                queryParams: function (params) {

                    var name = $('#name').val();  //获取查询表单name的值
                    var phone = $('#phone').val();
                    var status = $('#status').val();
                    var method = $('#method').val();
                    var begin = $('#beginRegisterDate').val(); //重置name
                    var end = $('#endRegisterDate').val(); //重置name


                    params.name = name;
                    params.phone = phone;
                    params.status = status;
                    params.method =method;
                    params.begin = begin;
                    params.end = end;
                    return params;
                },
                /**
                 * 决定了在哪边分页：client server, 两种不同的配置决定了服务器端返回的数据格式。
                 *  client分页, 服务器端返回的数据  [{}, {}, {}]
                 *  server端分页，服务器端返回的数据：{rows:[{}, {}], total: 23}
                 */
                sidePagination: 'server',
                pagination: true, //表示使用分页
                toolbar: '#goodsTableToolbar' , //设置工具条
                pageList: [4, 8, 12]
            })

            function formatStatus(value, row,index) {


                // return 'TRADE_SUCCESS' == value ? '<span class="label label-success">已支付</span>' : '<span class="label label-danger">不可用</span>';
                if ('TRADE_FAIL' == value) {
                    return '<span class="label label-danger">不可用</span>'
                }
                if ('TRADE_SUCCESS' == value) {
                    return '<span class="label label-success">已支付</span>'
                }
            }

            function formatMethod(value, row,index) {


                // return 'TRADE_SUCCESS' == value ? '<span class="label label-success">已支付</span>' : '<span class="label label-danger">不可用</span>';
                if (2 == value) {
                    return '<span class="label label-danger">微信支付</span>'
                }
                if (1 == value) {
                    return '<span class="label label-success">支付宝支付</span>'
                }
            }

            // 格式化日期
            function formatTime(value) {
                return moment(value).format('YYYY-MM-DD HH:mm:ss')
            }

            //当内容长度大于30的时候，多余的不显示
            function formatTitle(value) {
                var length = value.length; //获取文本长度
                if(length > 15) {
                    return value.substring(0, 16) + '...';
                }
                return value;
            }



            // 搜索
            function querySearch() {
                // 解决翻页之后, 还是停留在以前的页面问题, 使用selectPage, 意思是回到第一页
                $('#goodsDataTable').bootstrapTable('refresh');
            }

            function resetSearch() {
                $('#name').val(''); //重置name
                $('#phone').val(''); //重置性别
                $('#status').val('-1'); //重置状态
                $('#beginRegisterDate').val('');
                $('#endRegisterDate').val('');
                querySearch();
            }

            $('#beginRegisterDate, #endRegisterDate').datetimepicker({
                // 格式化 yyyy-mm-dd hh:ii:ss 年-月-日 时-分-秒
                format: 'yyyy-mm-dd hh:ii:ss'
            })

            function addProcessBtn(value, row) {

                var payId = row.payId;
                var payName =row.address.aname;


                return '<button onclick="getPayBtn(' + payId + ',\''+payName+'\')" class="btn btn-danger btn-xs">删除</button>'
            }



            function getPayBtn(payId,payName) {
                if(confirm("确定要删支付用户【" + payName + "】的数据?")){
                    $.ajax({
                        url: 'http://localhost:8080/pay/'+payId,
                        type: 'delete',
                        dataType: 'json',
                        success: function(_data) {

                            if(_data.code == 1) {
                                alert("删除成功")
                                $('#goodsDataTable').bootstrapTable('refresh');
                            }else {
                                alert("删除失败,请联系管理员")
                            }

                        }
                    })
                }
            }
            function loginOut(){

                $.ajax({
                    url:'http://localhost:8080/sysUser/loginOut',
                    method:'get',
                    success:function (_data) {
                        alert(_data.msg);
                        $.cookie('frontedUsername','',path='/');
                        window.location="/shop/login.html";
                    }

                })
            }
            $('#admin-name').hide();
            $('#admin-nam2').html('欢迎你'+$.cookie('frontedUsername'));
        </script>
        </html>